package com.neusoft.yuejian_6.model;

import com.neusoft.yuejian_6.javabean.Activity;
import com.neusoft.yuejian_6.javabean.Apply;
import com.neusoft.yuejian_6.javabean.Inform;
import com.neusoft.yuejian_6.javabean.Order;
import com.neusoft.yuejian_6.javabean.Post;
import com.neusoft.yuejian_6.javabean.Prize;
import com.neusoft.yuejian_6.javabean.User;

import com.neusoft.yuejian_6.service.ActivityService;
import com.neusoft.yuejian_6.service.UserService;

import java.util.List;

import retrofit2.Call;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

import static com.neusoft.yuejian_6.base.Constant.BASE_URL;

/**
 * Created by Mao on 2017/9/27.
 */
public class UserModel {
    private Retrofit retrofit;
    public UserModel(){
        retrofit = new Retrofit.Builder()
                //http://10.0.2.2/yuejian14/API/User/getUserLogin/
                //  http://172.24.10.175/workout/api.php/login/

                .baseUrl(BASE_URL)
                .addConverterFactory(GsonConverterFactory.create())
                .build();
    }
    public Call<User> login(String str_name, String str_password){
        UserService userService = retrofit.create(UserService.class);
        return userService.getUserLogin(str_name,str_password);
    }

    public Call<User> register(String str_name, String str_password, String str_phone, String str_age,String str_sex) {
        UserService userService = retrofit.create(UserService.class);
        return userService.getuserRegister(str_name,str_password,str_phone,str_age,str_sex);
    }
//    //报名活动
//    public Call<Apply> addactivityn(int user_id, int activity_id){
//        ActivityService activityService = retrofit.create(ActivityService.class);
//        return activityService.addactivityn(user_id,activity_id);
//    }

    //获取用户信息
    public Call<User> getUserInfo(int user_id) {
        UserService userService = retrofit.create(UserService.class);
        return userService.getUserInfo(user_id);
    }

    public Call<User> edituser(int user_id) {
        UserService userService = retrofit.create(UserService.class);
        return userService.edituser(user_id);
    }

    public Call<User> updateuser(int user_id, String user_name, String user_password, String user_phone) {
        UserService userService = retrofit.create(UserService.class);
        return userService.updateuser(user_id, user_name, user_password, user_phone);
    }

    public Call<List<Post>> getpostlist(int user_id) {
        UserService userService = retrofit.create(UserService.class);
        return userService.getpostlist(user_id);
    }

    public Call<List<Prize>> getprizelist(int user_id) {
        UserService userService = retrofit.create(UserService.class);
        return userService.getprizelist(user_id);
    }

    public Call<List<Order>> getorderlist(int user_id) {
        UserService userService = retrofit.create(UserService.class);
        return userService.getorderlist(user_id);
    }

    public Call<List<Inform>> getinformlist(int user_id) {
        UserService userService = retrofit.create(UserService.class);
        return userService.getinformlist(user_id);
    }


    //详情
    public Call<Prize> getPrizeById(int user_id){
        UserService userService=retrofit.create(UserService.class);
        return userService.getPrizeById(user_id);
    }
    //查看我关注的活动
    public Call<List<Activity>> getMyCollectActivity(int user_id, String flag) {
        UserService userService = retrofit.create(UserService.class);
        return userService.getMyCollectActivity(user_id,flag);
    }

}
